<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org" layout:decorate="main"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head>
    <title>处方划价</title>
    <link th:href="@{/localcss/crmlist.css}" href="../static/localcss/crmlist.css" rel="stylesheet">
    <style>
        #biaoge1 {
            float: left;
            margin-left: 30%;
            margin-top: -4%;
        }

        .dataFrm_input {
            float: right;
            margin-left: 10%;
            font-size: 16px;
            width: 150px;
            height: 20px;
            margin-right: 20px;
            margin-bottom: 8px;
        }

        .dataFrm_td {
            display: block;
            width: 80px;
            text-align: right;
        }

        #niu {
            width: 530px;
            border-style: solid;
            margin-top: 100px;
            height: 300px;
        }
        #niu2 {
            float: right;
            width: 530px;
            border-style: solid;
            margin-top: -300px;

            height: 300px;
        }
        #datatable-responsive2{
            margin-top:50px;
        }

    </style>
</head>
<body>
<div layout:fragment="content" style="height: 1000px;background-color:#FAFAFA">
    <div class="clearfix"></div>
    <div class="col-md-12">
        <div class="x_panel" id="wj">
            <div class="x_title">
                <h2>
                    缴费管理 <i class="fa fa-user"></i>
                    <small>
                        - 您可以通过搜索或者其他的筛选项对用户的信息进行编辑、删除等管理操作。^_^
                    </small>
                </h2>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <form method="post" >
                    <input type="hidden" name="pageIndex" value="1"/>
                    <ul>
                        <li>
                            <div class="form-group">
                                <label class="col-md-3 ">编号</label>
                                <div class="col-md-6 col-sm-6 col-xs-12" style="margin-left: -50px">
                                    <input type="number" name="registerid" id="shows" lay-verify="required|number"
                                           autocomplete="off" class="layui-input" style="width:150px;height: 35px">
                                </div>

                                <button type="button" class="btn btn-primary" id="chazhao" > 查&nbsp;&nbsp;&nbsp;&nbsp;询
                                </button>
                            </div>

                        </li>

                        <div id="biaoge1">
                            <input type="hidden" id="show" name="registerid">
                            <input type="hidden" id="hidden" name="moneys" value="0">
                            <table>
                                <tr>
                                    <td class="dataFrm_td">姓名：</td>
                                    <td><input type="text" id="userName" class="dataFrm_input" name="userName" readonly>
                                    </td>
                                    <td class="dataFrm_td">科室：</td>
                                    <td><input type="text" id="department" class="dataFrm_input" name="department"
                                               readonly></td>
                                    <td class="dataFrm_td">金额：</td>
                                    <td><input type="text" id="money" class="dataFrm_input" name="money" readonly></td>
                                </tr>
                                <tr>
                                    <td class="dataFrm_td">性别：</td>
                                    <td><input type="text" id="sex" class="dataFrm_input" name="sex" readonly></td>
                                    <td class="dataFrm_td"> 医生：</td>
                                    <td><input type="text" class="dataFrm_input" name="doctorName" id="doctorName"
                                               readonly></td>
                                    <td class="dataFrm_td">已用：</td>
                                    <td><input type="text" class="dataFrm_input" id="yong" readonly></td>
                                </tr>
                                <tr>
                                    <td class="dataFrm_td">年龄：</td>
                                    <td><input type="text" class="dataFrm_input" name="age" id="age" readonly></td>
                                    <td class="dataFrm_td">床位：</td>
                                    <td><input type="text" class="dataFrm_input" name="bedName" id="bedName" readonly>
                                    </td>
                                    <td class="dataFrm_td">余款：</td>
                                    <td><input type="text" class="dataFrm_input" id="yu" readonly></td>
                                </tr>
                            </table>
                        </div>
                    </ul>
                </form>
            </div>
            <div id="niu">
                <form action="/hospital/drug">
                <div class="form-group">

                    <div class="col-md-6 col-sm-6 col-xs-12">
                        <input type="text" name="pharmacyName" id="num" lay-verify="required|number" autocomplete="off"
                               class="layui-input" style="width:160px;height: 30px" placeholder="请输入查询的药品名称">
                    </div>
                    <button type="submit" class="btn btn-primary" id="cz" style="margin-left: -80px"> 查 &nbsp;&nbsp;&nbsp;&nbsp;询</button>
                </div>
                <table id="datatable-responsive"
                       class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
                       cellspacing="0" width="100%" role="grid"
                       aria-describedby="datatable-responsive_info" style="width: 100%;">
                    <thead>
                    <tr role="row">
                        <th>药品序号
                        </th>

                        <th>
                            药品名称
                        </th>
                        <th>
                            计量单位
                        </th>
                        <th>
                            售价
                        </th>
                        <th>
                            数量
                        </th>

                        <th>
                            操作
                        </th>
                    </tr>

                    </thead>

                    <tbody id="nd">
                    <!--<tr role="row" class="odd" th:each="list:${drug.records}">-->
                        <!--<td tabindex="0" class="sorting_1" th:value="${list.getPharmacyId()}"-->
                            <!--th:text="${list.getPharmacyId()}" th:name="pharmacyId">-->
                        <!--</td>-->
                        <!--<td th:text="${list.getPharmacyName()}">pharmacyName</td>-->
                        <!--<td th:text="${list.getUnitName()}">unitName</td>-->
                        <!--<td th:text="${list.getSellingPrice()}">sellingPrice</td>-->
                        <!--<td th:text="${list.getDrugstorenum()}">drugstorenum</td>-->
                        <!--<td>-->
                            <!--<div id="zhuanke">-->
                                <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="upd"-->
                                        <!--style="background-color: #5bc0de">转科-->
                                <!--</button>-->
                            <!--</div>-->
                        <!--</td>-->
                    <!--</tr>-->
                    </tbody>
                </table>

                </form>
            </div>

        </div>
    </div>

</div>
</body>
<script layout:fragment="js">
    var pharmacyId = "";
    var pharmacyName = "";
    $(document).ready(function(){
        $.ajax({
            type: "post",
            url: '/hospital/selDrug',
            data: {"pharmacyId": pharmacyId, "pharmacyName": pharmacyName},
            dataType: 'json',
            success: function (data) {
                console.info(data.records)
                $(data.records).each(function () {
                    var cha = "<tr role=\"row\" class=\"odd\" >"+"<td>"+this.pharmacyId+"</td><td>"+this.pharmacyName+
                        "</td><td>"+this.unitName+"</td><td>"+this.sellingPrice+"</td><td>"+this.drugstorenum+
                        "</td>"+"<td><div><button type=\"button\" class=\"layui-btn layui-btn-sm\" lay-event=\"upd\"style=\"background-color: #5bc0de\">添加" +
                        "</button>"+"</div>"+"</td>"+"</tr>"
                    $("#nd").after(cha)

                })

                // var pagepj = "<div id='x_page1' class=\"row\">\n" +
                //     "                                        <div class=\"col-sm-5\">\n" +
                //     "                                            <div class=\"dataTables_info\" id=\"datatable-responsive_info\"\n" +
                //     "                                                 role=\"status\" aria-live=\"polite\">共<span\n" +
                //     "                                                    th:text=\"${paylist.totalElements}\">" + data.size+ "</span>条记录\n" +
                //     "                                                <span th:text=\"${paylist.number+1 }\">" + data.current + "</span>/<span\n" +
                //     "                                                        th:text=\"${paylist.totalPages }\">" + data.pages + "</span>页\n" +
                //     "                                            </div>\n" +
                //     "                                        </div>\n" +
                //     "                                        <div class=\"col-sm-7\">\n" +
                //     "                                            <div class=\"dataTables_paginate paging_simple_numbers\"\n" +
                //     "                                                 id=\"datatable-responsive_paginate\">\n" +
                //     "                                                <ul class=\"pagination\">\n" +
                //     "                                                    <li class=\"paginate_button previous\" th:if=\'${" + data.current + " gt 0}\'><a\n" +
                //     "                                                            href=\"javascript:page_navg(1,"+registerid+");\"\n" +
                //     "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"0\"\n" +
                //     "                                                            tabindex=\"0\">首页</a>\n" +
                //     "                                                    </li>\n" +
                //     "                                                    <li class=\"paginate_button \" th:if=\'${" + data.current + " gt 0}\'><a\n" +
                //     "                                                            href=\"javascript:page_navg(" + (data.current - 1) + ","+registerid+");\"\n" +
                //     "                                                            th:onclick=\"'javascript:page_navg(" + (data.current - 1) + ","+registerid+");'\"\n" +
                //     "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                //     "                                                            tabindex=\"0\">上一页</a>\n" +
                //     "                                                    </li>\n" +
                //     "                                                    <li class=\"paginate_button \"\n" +
                //     "                                                        th:if=\'${(" + (data.current + 1) + ") lt " + data.pages + "}\'><a\n" +
                //     "                                                            href=\"javascript:page_navg(" + (data.current + 1) + ","+registerid+");\"\n" +
                //     "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                //     "                                                            tabindex=\"0\">下一页</a>\n" +
                //     "                                                    </li>\n" +
                //     "                                                    <li class=\"paginate_button next\"\n" +
                //     "                                                        th:if=\'${(" + (data.current + 1) + ") lt " + data.pages + "}\'><a\n" +
                //     "                                                            href=\"javascript:page_navg(" + data.pages + ","+registerid+");\"\n" +
                //     "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"7\"\n" +
                //     "                                                            tabindex=\"0\">最后一页</a>\n" +
                //     "                                                    </li>\n" +
                //     "                                                </ul>\n" +
                //     "                                            </div>\n" +
                //     "                                        </div>\n" +
                //     "                                    </div>";
                // $("#datatable-responsivey").after(pagepj);


            }

        });
    });
    $("#chazhao").click(function () {
        registerid = $("#shows").val()
        alert(registerid)
        $.getJSON("/hospital/selPay", {"registerid": registerid}, function (data) {
            $(data).each(function () {
                $("#userName").val(this.userName)
                $("#department").val(this.department)
                $("#money").val(this.money)
                $("#doctorName").val(this.doctorName)
                $("#sex").val(this.sex)
                $("#age").val(this.age)
                $("#bedName").val(this.bedName)
                alert(this.userName)
            })
        });
        tianchong(registerid,0);
        return false;
    });
    function tianchong(registerid,state) {
        $.ajax({
            type: "post",
            url: '/hospital/selDrugs',
            data: {"registerid": registerid, "state": state},
            dataType: 'json',
            success: function (data) {
                console.info(data.records)
                var select = "<div id='niu2'>\n" + "<table id=\"datatable-responsive2\"\n" +
                    "                       class=\"table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed\"\n" +
                    "                       cellspacing=\"0\" width=\"100%\" role=\"grid\"\n" +
                    "                       aria-describedby=\"datatable-responsive_info\" style=\"width: 100%;\">" + "<thead>" + "<tr role=\"row\">" + "<th>序号</th>" + "<th>药品名称</th>"
                    + "<th>数量</th>" + "<th>售价</th>" + "<th>总价</th>"
                    + "<th>操作</th>" + "</tr>" + "</thead>" + "<tbody>";
                $(data.records).each(function () {
                    var cha = "<tr role=\"row\" class=\"odd\" >"+"<td>"+this.hospitalpriceid+"</td><td>"+this.durgname+
                        "</td><td>"+this.durgnum+"</td><td>"+this.repiceprice+"</td><td>"+this.repicetotal+
                        "</td>"+"<td><div><button type=\"button\" class=\"layui-btn layui-btn-sm\" lay-event=\"upd\"style=\"background-color: #5bc0de\">转科" +
                        "</button>"+"</div>"+"</td>"+"</tr>"
                    select+=cha;
                })
                var zhao="</tbody>"+ "</table>";
                        var pagepj = "<div id='x_page1' class=\"row\">\n" +
                            "                                        <div class=\"col-sm-5\">\n" +
                            "                                            <div class=\"dataTables_info\" id=\"datatable-responsive_info\"\n" +
                            "                                                 role=\"status\" aria-live=\"polite\">共<span\n" +
                            "                                                    th:text=\"${paylist.totalElements}\">" + data.size+ "</span>条记录\n" +
                            "                                                <span th:text=\"${paylist.number+1 }\">" + data.current + "</span>/<span\n" +
                            "                                                        th:text=\"${paylist.totalPages }\">" + data.pages + "</span>页\n" +
                            "                                            </div>\n" +
                            "                                        </div>\n" +
                            "                                        <div class=\"col-sm-7\">\n" +
                            "                                            <div class=\"dataTables_paginate paging_simple_numbers\"\n" +
                            "                                                 id=\"datatable-responsive_paginate\">\n" +
                            "                                                <ul class=\"pagination\">\n" +
                            "                                                    <li class=\"paginate_button previous\" th:if=\'${" + data.current + " gt 0}\'><a\n" +
                            "                                                            href=\"javascript:page_navg(1,"+registerid+");\"\n" +
                            "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"0\"\n" +
                            "                                                            tabindex=\"0\">首页</a>\n" +
                            "                                                    </li>\n" +
                            "                                                    <li class=\"paginate_button \" th:if=\'${" + data.current + " gt 0}\'><a\n" +
                            "                                                            href=\"javascript:page_navg(" + (data.current - 1) + ","+registerid+");\"\n" +
                            "                                                            th:onclick=\"'javascript:page_navg(" + (data.current - 1) + ","+registerid+");'\"\n" +
                            "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                            "                                                            tabindex=\"0\">上一页</a>\n" +
                            "                                                    </li>\n" +
                            "                                                    <li class=\"paginate_button \"\n" +
                            "                                                        th:if=\'${(" + (data.current + 1) + ") lt " + data.pages + "}\'><a\n" +
                            "                                                            href=\"javascript:page_navg(" + (data.current + 1) + ","+registerid+");\"\n" +
                            "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                            "                                                            tabindex=\"0\">下一页</a>\n" +
                            "                                                    </li>\n" +
                            "                                                    <li class=\"paginate_button next\"\n" +
                            "                                                        th:if=\'${(" + (data.current + 1) + ") lt " + data.pages + "}\'><a\n" +
                            "                                                            href=\"javascript:page_navg(" + data.pages + ","+registerid+");\"\n" +
                            "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"7\"\n" +
                            "                                                            tabindex=\"0\">最后一页</a>\n" +
                            "                                                    </li>\n" +
                            "                                                </ul>\n" +
                            "                                            </div>\n" +
                            "                                        </div>\n" +
                            "                                    </div>";
                        $("#datatable-responsivey").after(pagepj);
                       select+=zhao;
                        $("#niu").after(select)
                    }

                });
    }

</script>